package com.cy.pj.goods.dao.Impl;

import com.cy.pj.goods.dao.GoodsDao;
import com.cy.pj.goods.pojo.Goods;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


public class GoodsDaoImpl implements GoodsDao {

    @Autowired
    private SqlSession sqlSession;

    @Override
    public List<Goods> findGoods(){
        //String namespace="com.cy.pj.goods.dao.GoodsDao";
        //String elementId="findGoods";
        String namespace = this.getClass().getInterfaces()[0].getName();
        String elementId = Thread.currentThread().getStackTrace()[1].getMethodName();
        String statement = namespace+"."+elementId;
        List<Goods> list=sqlSession.selectList(statement);
        return list;
    }

    /*@Override
    public List<Goods> findGoods(){
        String namespace="com.cy.pj.goods.dao.GoodDao";
        String elementId="findGoods";
        String statement = namespace+"."+elementId;
        List<Goods> list=sqlSession.selectList(statement);
        return list;
    }*/
}
/*public List<Goods> findGoods(){
        Connection conn;
        Statement stat;
        ResultSet rs;
        String sql = "select * from tb_goods";
        try {
            conn = sqlSession.getConnection();
            stat = conn.createStatement();
            rs = stat.executeQuery(sql);
            while (rs.next()){

            }
            return null;
        }catch (Exception e){
            e.printStackTrace();
        }finally {

        }
        //mybatis数据访问实现

    }*/
